import React from 'react';
import { connect } from 'dva';
import PropTypes from 'prop-types';
import {Menu, Icon } from 'antd';
import './TopNav.css';
const { SubMenu } = Menu;

const TopNav = React.createClass({
	handleClick(e){
		switch(e.key){
			case "1":
				let data1 = {
					tabs:[
						{
							tabName:'通用列表',
							tabLink:'comList',
        					tabIcon:'bars'
						},
						{
							tabName:'修改密码',
							tabLink:'editPassword',
        					tabIcon:'edit'
						},
					    {
					      	SubMenuTabName:'一级菜单1',
      						SubMenuTabIcon:'appstore',
					      	tabList:[
					      		{
							        tabName:'通用表单',
							        tabLink:'comForm',
        							tabIcon:'edit'
							      },
							      
					      		{
							        tabName:'通用列表',
							        tabLink:'comList',
        							tabIcon:'bars'
							      },
					      	]
					    }
					]
			    };
			   	this.props.dispatch({
			      	type:'common/changeLeftNav',
			      	payload:data1
			    });
			    break;
			case "2":
				let data2 = {
					tabs:[
						{
					      	SubMenuTabName:'内容A管理',
      						SubMenuTabIcon:'appstore',
					      	tabList:[
					      		{
							        tabName:'内容A列表',
							        tabLink:'comList',
        							tabIcon:'bars'
							      },
					      		{
							        tabName:'新增内容A',
							        tabLink:'comForm',
        							tabIcon:'edit'
							      }
					      	]
					   },
						{
					      	SubMenuTabName:'内容B管理',
      						SubMenuTabIcon:'appstore',
					      	tabList:[
					      		{
							        tabName:'内容B列表',
							        tabLink:'comList',
        							tabIcon:'bars'
							      },
					      		{
							        tabName:'新增内容B',
							        tabLink:'comForm',
        							tabIcon:'edit'
							      }
					      	]
					    }
					]
			    };
			   	this.props.dispatch({
			      	type:'common/changeLeftNav',
			      	payload:data2
			    });
			    break;
			default:
				return false;
		}
	},
	render(){
		return (
			<Menu onClick={this.handleClick}
			mode="horizontal"
			theme="dark"
			className="topnav"
			>
				<Menu.Item key="1">基础设置</Menu.Item>
				<Menu.Item key="2">内容管理</Menu.Item>
				<Menu.Item key="3">会员管理</Menu.Item>
				<Menu.Item key="4">广告管理</Menu.Item>
			</Menu>		
		)
	}
})

function mapStateToProps({ common }) {
return {common};
}
export default connect(mapStateToProps)(TopNav);
//export default TopNav;